package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.domain.FailLog;
import cn.wolfcode.crm.mapper.FailLogMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IFailLogService;
import cn.wolfcode.crm.util.PageResult;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

@Service
public class FailLogServiceImpl implements IFailLogService {

    @Autowired
    private FailLogMapper failLogMapper;

    @Override
    public FailLog selectByPrimaryKey(Long id) {
        return failLogMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<FailLog> selectAll() {
        return failLogMapper.selectAll();
    }

    @Override
    public PageResult query(QueryObject qo) {
        int total = failLogMapper.query4Count(qo);
        if(total == 0 ){
            return new PageResult(0, Collections.EMPTY_LIST);
        }
        List<?> rows = failLogMapper.query4List(qo);
        return new PageResult(total,rows);
    }

    @Override
    public void insert(FailLog entity) {
        entity.setInputDate(new Date());
        failLogMapper.insert(entity);
    }
}
